<script lang="ts" setup>
import { useTheme } from 'vuetify'

const items = [
  { icon: 'mdi-email', title: 'Click Me 1', color: 'purple' },
  { icon: 'mdi-email', title: 'Click Me 2', color: 'orange' },
  { icon: 'mdi-email', title: 'Click Me 3', color: 'red' },
  { icon: 'mdi-email', title: 'Click Me 4', color: 'blue' }
]
const theme = useTheme()
const darkTheme = ref(false)

function changeTheme() {
  darkTheme.value = !darkTheme.value
  initTheme()
}

function initTheme() {
  theme.global.name.value = darkTheme.value ? 'dark' : 'light'
}

onMounted(() => {
  initTheme()
})
</script>

<template>
  <v-toolbar density="compact">
    <v-app-bar-nav-icon></v-app-bar-nav-icon>

    <v-toolbar-title>
      <RouterLink to="/">ZIC</RouterLink>
    </v-toolbar-title>

    <v-spacer></v-spacer>

    <v-menu transition="scale-transition">
      <template v-slot:activator="{ props }">
        <v-btn v-bind="props" icon>
          <v-badge content="6" size="x-small" color="red-darken-2">
            <v-icon color="blue-darken-4">mdi-bell</v-icon>
          </v-badge>
        </v-btn>
      </template>
      <v-list>
        <v-list-item v-for="(item, index) in items" :key="index" :value="index">
          <v-list-item-title>
            <v-icon :color="item.color">{{ item.icon }}</v-icon>
            {{ item.title }}
          </v-list-item-title>
        </v-list-item>
      </v-list>
    </v-menu>

    <v-btn icon @click="changeTheme">
      <v-icon :icon="darkTheme ? 'mdi-weather-sunny' : 'mdi-weather-night'"></v-icon>
    </v-btn>

    <!-- <v-btn icon>
        <v-icon>mdi-weather-sunny</v-icon>
      </v-btn> -->

    <!--       <v-btn icon>
        <v-icon>mdi-magnify</v-icon>
      </v-btn>

      <v-btn icon>
        <v-icon>mdi-heart</v-icon>
      </v-btn>

      <v-btn icon>
        <v-icon>mdi-dots-vertical</v-icon>
      </v-btn> -->

    <v-btn to="/login" variant="outlined" color="pink-darken-4" size="small" text="登录"></v-btn>
  </v-toolbar>
</template>

<style scoped>
header {
  line-height: 1.5;
  max-height: 100vh;
}

.logo {
  display: block;
  margin: 0 auto 2rem;
}

nav {
  width: 100%;
  font-size: 12px;
  text-align: center;
  margin-top: 2rem;
}

nav a.router-link-exact-active {
  color: var(--color-text);
}

nav a.router-link-exact-active:hover {
  background-color: transparent;
}

nav a {
  display: inline-block;
  padding: 0 1rem;
  border-left: 1px solid var(--color-border);
}

nav a:first-of-type {
  border: 0;
}

@media (min-width: 1024px) {
  header {
    display: flex;
    place-items: center;
    padding-right: calc(var(--section-gap) / 2);
  }

  .logo {
    margin: 0 2rem 0 0;
  }

  header .wrapper {
    display: flex;
    place-items: flex-start;
    flex-wrap: wrap;
  }

  nav {
    text-align: left;
    margin-left: -1rem;
    font-size: 1rem;

    padding: 1rem 0;
    margin-top: 1rem;
  }
}
</style>
